//
//  CommentCell.swift
//  WangPu
//
//  Created by xiaozhi on 15/10/16.
//  Copyright © 2015年 zhixiao. All rights reserved.
//

import UIKit

class CommentCell: UITableViewCell {
    var startView:StarsView!
    var commentName:UILabel!
    var commentTime:UILabel!
    var content:UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)

    }
    func layoutWithData(data:CommentObj){
        contentView.frame = bounds
        startView = StarsView(frame: CGRectMake(10, 5, 75, 15));
        startView.setSelectNumber(5)
        contentView.addSubview(startView)
        commentName = UILabel(frame: CGRectMake(contentView.bounds.size.width-250, 5,110, 20))
        commentName.text = data.nickname
        commentName.textColor = UIColor.darkGrayColor()
        commentName.textAlignment = NSTextAlignment.Center
        commentName.font = UIFont.systemFontOfSize(12)
        contentView.addSubview(commentName)
        commentTime = UILabel(frame: CGRectMake(contentView.bounds.size.width-140, 5,130, 20))
        commentTime.text = data.created_at
        commentTime.textColor = UIColor.darkGrayColor()
        commentTime.textAlignment = NSTextAlignment.Right
        commentTime.font = UIFont.systemFontOfSize(12)
        contentView.addSubview(commentTime)
        
        content = UILabel(frame: CGRectMake(15, 30,contentView.bounds.size.width-30, bounds.size.height - 30))
        print(content.frame)

        content.numberOfLines = 0
        content.text =  data.detail
        content.textColor = UIColor.darkGrayColor()
        content.textAlignment = NSTextAlignment.Left
        content.font = UIFont.systemFontOfSize(12)
        contentView.addSubview(content)
        
        let sepView = UIView(frame: CGRectMake(0, CGRectGetMaxY(content.frame), bounds.size.width, onePix))
        sepView.backgroundColor = commonBackgoundColor
        contentView.addSubview(sepView)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
//        startView.frame = CGRectMake(10, 5, 150, 20)
    }
    required   init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
}
